import {reqCategoryList,reqBannerList,reqFloorList,reqUserInfo} from "@/api"

//home的小仓库

const actions = {
  //三级联动请求
  async categoryList({commit}){
       const result = await reqCategoryList()
       if(result.code == 200) {
        //删掉最后一个元素
        result.data.pop()
        commit('CATEGORYLIST',result.data)
       }
   },

   //banner请求
   async bannerList({commit}){
      const result =  await reqBannerList()
      if(result.code == 200) {
        commit('BANNERLIST',result.data)
      }
   },

   //floor请求
   async floorList({commit}){
    const result = await reqFloorList()
    if(result.code == 200){
      commit('FLOORLIST',result.data)
    }
   },

  
}

const mutations = {
  // 存储三级联动的数据
  CATEGORYLIST(state,categoryList){
    state.categoryList = categoryList
  },
  // 存储banner轮播图的数据
  BANNERLIST(state,bannerList) {
      state.bannerList = bannerList
  },
  // 存储floor的数据
  FLOORLIST(state,floorList) {
      state.floorList = floorList
  }
}

const state = {
  //存储三级联动的数据
    categoryList : [],
  //存储banner的数据
    bannerList : [],
  //存储floor的数据
    floorList : []
}

const getters = {

}

export default {
  namespaced:true,
  actions,
  mutations,
  state,
  getters
}